#ifndef COMPASS_H_
#define COMPASS_H_

#include "Wire/Wire.h"

#define I2C_ADDRESS 0x42 >> 1

#define WRITE_RAM 'G'
#define RESET 'O'
#define GET_HEADING 'A'
#define EXIT_CALIBRATION 'E'
#define START_CALIBRATION 'C'

#define OPERATION_MODE_ADDRESS 0x74
#define CONTINUOUS_MODE_20HZ UPDATE_RATE_20HZ | AUTOMATIC_SR | CONTINUOUS_MODE
#define UPDATE_RATE_20HZ 0b01100000
#define AUTOMATIC_SR 0b00010000
#define CONTINUOUS_MODE 0b00000010

#define CALIBRATION_TIME 10000

class Compass {
public:
  unsigned int heading();
  void reset(unsigned int course);
  void initialize();
  void setOperationMode();
  void exitCalibration();
  void startCalibration();
  void getHeading();
};

#endif /* COMPASS_H_ */
